package com.zyp.dao;

import com.zyp.entity.Transaction;
import com.zyp.utils.DateUtils;
import com.zyp.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

public class TransactionDao {

    private QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());

    //编写记录表的插入操作
    public int add(Transaction transaction) throws SQLException {
        //编写SQL
        String sql = "insert into transaction values(?,?,?,?,?)";
        Object[] param = {null, transaction.getCardid(), transaction.getTratype(), transaction.getTramoney(), DateUtils.getDateFormart()};
        //插入操作
        int update = qr.update(sql, param);

        return update;
    }
}
